Skip to content

Method: static {...}

1: /**
2: * Copyright (C) 2020 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jopa.owl2java;
16:
17: import cz.cvut.kbss.jopa.model.SequencesVocabulary;
18: import org.semanticweb.owlapi.model.*;
19:
20: import java.util.Arrays;
21: import java.util.HashSet;
22: import java.util.Set;
23: import java.util.TreeSet;
24:
25: class ContextDefinition {
26:
27: /**
28: * OWLEntities to skip
29: */
30: private static final Set<IRI> SKIPPED = new HashSet<>(
31: Arrays.asList(IRI.create(SequencesVocabulary.c_Collection), IRI.create(SequencesVocabulary.c_List),
32: IRI.create(SequencesVocabulary.c_OWLSimpleList),
33: IRI.create(SequencesVocabulary.c_OWLReferencedList)));
34:
35: final Set<OWLAxiom> axioms = new HashSet<>();
36: final Set<OWLClass> classes = new TreeSet<>();
37: final Set<OWLObjectProperty> objectProperties = new TreeSet<>();
38: final Set<OWLDataProperty> dataProperties = new TreeSet<>();
39: final Set<OWLAnnotationProperty> annotationProperties = new TreeSet<>();
40: final Set<OWLNamedIndividual> individuals = new TreeSet<>();
41:
42: IntegrityConstraintSet set;
43:
44: void parse() {
45: final IntegrityConstraintParser parser = new IntegrityConstraintParser();
46: for (final OWLAxiom a : axioms) {
47: a.accept(parser);
48: }
49: this.set = parser.getClassIntegrityConstraintSet();
50: }
51:
52: void addAxiom(OWLAxiom axiom) {
53: axiom.signature().filter(e -> !SKIPPED.contains(e.getIRI())).forEach(this::add);
54: axioms.add(axiom);
55: }
56:
57: void add(OWLEntity e) {
58: if (e.isOWLClass()) {
59: classes.add(e.asOWLClass());
60: } else if (e.isOWLObjectProperty()) {
61: objectProperties.add(e.asOWLObjectProperty());
62: } else if (e.isOWLDataProperty()) {
63: dataProperties.add(e.asOWLDataProperty());
64: } else if (e.isOWLAnnotationProperty()) {
65: annotationProperties.add(e.asOWLAnnotationProperty());
66: } else if (e.isOWLNamedIndividual()) {
67: individuals.add(e.asOWLNamedIndividual());
68: }
69: }
70: }